<template>
	<view class="container">
		<uni-section title="食物轮播图展示" sub-title="" type="line">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" duration="1000">
				<swiper-item v-for="item in swiperList">
					<image :src="'http://localhost:8090/'+item.icon" mode="" style="width: 100%;height: 150px;"></image>
				</swiper-item>
			</swiper>
		</uni-section>
		<uni-section title="食物类别宫格展示" sub-title="" type="line">
			<!-- highlight="true" -->
			<uni-grid :column="3" >
				<uni-grid-item v-for="item in foodgridList">
					<view style="display: flex;flex:1;flex-directtion: column; justify-content: center;align-items: center;">
						<image :src="'http://localhost:8090/'+item.icon" mode="" style="width: 80px; height: 80px;">
						</image>
						<view class="">{{item.typename}}</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</uni-section>
		<uni-section title="食物列表展示" sub-title="" type="line">
			<uni-list v-for="(item,index) in foodList" v-if="index <  3">
				<navigator :url="'../fooddetail/fooddetail?id='+item.id">
				<uni-list-item :title="item.name" :thumb="'http://localhost:8090/'+item.icon" :rightText="'￥'+item.price">
				</uni-list-item>	
				</navigator>
			</uni-list>
		</uni-section>
		<uni-section title="食物评论列表展示" sub-title="" type="line">
		    <uni-list v-for="(item,index) in commentList">
		    	<uni-list-item :title="item.comment" note="" :rightText="item.postdate" v-if="index < 3"></uni-list-item>
		    </uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperList:[],
				foodgridList:[],
				foodList:[],
				commentList:[]
			}
		},
		methods: {
         swiperm(){
			 uni.request({
			 	url: 'http://localhost:8090/foodapp/foodSwiper/list',
			 	method: 'POST',
			 	data: {},
			 	success: res => {
					if(res.data.success){
						this.swiperList = res.data.list
						console.log("1312",this.swiperList);
					}
				},
			 	fail: () => {},
			 	complete: () => {}
			 });
		 },
		 foodgrid(){
			 uni.request({
			 	url: 'http://localhost:8090/foodapp/foodType/list',
			 	method: 'POST',
			 	data: {},
			 	success: res => {
					if(res.data.success){
						this.foodgridList = res.data.list
					}
				},
			 	fail: () => {},
			 	complete: () => {}
			 });
		 },
		 foodListm(){
			 uni.request({
			 	url: 'http://localhost:8090/foodapp/food/list',
			 	method: 'POST',
			 	data: {},
			 	success: res => {
					if (res.data.success) {
						this.foodList = res.data.list
						console.log('wer',this.foodList);
					}
				},
			 	fail: () => {},
			 	complete: () => {}
			 });
		 },
		 commentListm(){
			 uni.request({
			 	url: 'http://localhost:8090/foodapp/comment/list',
			 	method: 'POST',
			 	data: {},
			 	success: res => {
					if (res.data.success) {
						this.commentList = res.data.list
					}
				},
			 	fail: () => {},
			 	complete: () => {}
			 });
		 }
		},
		onLoad(){
			this.swiperm(),
			this.foodgrid(),
			this.foodListm(),
			this.commentListm()
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
